package masterjava.common.client.gxt.base.rpc;

import com.extjs.gxt.ui.client.widget.Component;
import masterjava.common.client.gwt.rpc.CallbackAdapter;

/**
 * User: gkislin
 * Date: 7/28/11
 */
public abstract class MaskCallbackAdapter<T> extends CallbackAdapter<T> {
    private Component maskComponent;

    protected MaskCallbackAdapter(Component maskComponent) {
        this.maskComponent = maskComponent;
        maskComponent.mask("Loading", "x-mask-loading");
    }

    protected MaskCallbackAdapter(Component maskComponent, String msg) {
        this.maskComponent = maskComponent;
        maskComponent.mask(msg, "x-mask-loading");
    }

    @Override
    public void onFailure(Throwable e) {
        maskComponent.unmask();
        super.onFailure(e);
    }

    @Override
    public void onSuccess(T result) {
        maskComponent.unmask();
        super.onSuccess(result);
    }
}
